<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 数据代理就时通过一个对象去操作另一个对象的属性（读/写）-->
    <script type="text/javascript">
        let obj1 = {x:100};
        let obj2 = {y:200};

        
        Object.defineProperty(obj2,"x",{
            //访问obj2的x的时候，返回obj1的x值
            get(){
                return obj1.x;
            },
            //修改obj2的x值的时候，同时将obj1的x值修改
            set(value){
                obj1.x=value;
            }
        })
    </script>
</body>
</html>